home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / ae / code / ax3.00 / displaynodeclog.c < prev    next >
Encoding:
C/C++ Source or Header  |  1980-01-03  |  4.6 KB  |  144 lines

  1. #include "bbs.h"
  2.  
  3. static void DisplayCallerslog(char *filename,long tf)
  4. {
  5.  #define MEMSIZE 4096
  6.  long stat,stat2,loop,lnlp=0,ReadSize,CurrentPos;
  7.  UBYTE *buf;
  8.  BPTR fh;
  9.  
  10.  ReadSize=MEMSIZE;
  11.  LineCount=gnsflag=0;
  12.  if(tf)  gnsflag=1;
  13.  
  14.  if(buf=AllocMem(MEMSIZE+4,MEMF_ANY))    {
  15.      if(fh=Open(filename,MODE_OLDFILE)) {
  16.          Seek(fh,0,OFFSET_END);
  17.          CurrentPos=Seek(fh,0,OFFSET_CURRENT);
  18.          do  {
  19.              if(CurrentPos<MEMSIZE) {
  20.                  ReadSize=CurrentPos+lnlp;
  21.                  CurrentPos=0;
  22.              } else   CurrentPos=(CurrentPos-4096)+lnlp;
  23.  
  24.              stat=Seek(fh,CurrentPos,OFFSET_BEGINNING);
  25.              if(stat>=0) {
  26.                  Seek(fh,0,OFFSET_CURRENT);
  27.                  if((stat=Read(fh,buf,ReadSize))>0) {
  28.                      buf[ReadSize-1]='\0';
  29.                      lnlp=0;
  30.                      for(loop=ReadSize; loop>0; loop--) {
  31.                          if(buf[loop]=='\n') {
  32.                              sprintf(GSTR2,"%s\r\n",buf+loop+1);
  33.                              AEPutStr(GSTR2);
  34.                              buf[loop]='\0';
  35.                              lnlp=loop+1;
  36.                              if(stat2=CheckForPause()) {
  37.                                  AEPutStr("\r\n");
  38.                                  loop=0;
  39.                                  stat=(-1);
  40.                              }
  41.                              if(SCheckInput()) {
  42.                                  stat2=ReadChar(1L);
  43.                                  if(stat2<0) {
  44.                                      loop=0;
  45.                                      stat=(-1);
  46.                                  } else {
  47.                                      switch(stat2) {
  48.                                          case '\023': /* Pause */
  49.                                              stat=ReadChar(KEYBOARD_TIMEOUT);
  50.                                              if(stat2<0) {
  51.                                                  loop=0;
  52.                                                  stat=(-1);
  53.                                              }
  54.                                              break;
  55.                                          case '\003': /* ^C */
  56.                                              AEPutStr("**Break\r\n\r\n");
  57.                                              if(AnsiColor)  AEPutStr("");
  58.                                              loop=0;
  59.                                              stat=(-1);
  60.                                              break;
  61.                                      }
  62.                                  }
  63.                              }
  64.                          }
  65.                      }
  66.                  }
  67.                  if(stat<0) {
  68.                      stat=IoErr();
  69.                      if(stat>0) {
  70.                          //sprintf(GSTR2,"IOErr #%d\r\n",stat);
  71.                          //AEPutStr(GSTR2);
  72.                      }
  73.                      stat=(-1);
  74.                  }
  75.              }
  76.          } while(CurrentPos>0&&stat>=0);
  77.          Close(fh);
  78.      } else   AEPutStr("\r\nNot a valid node!\r\n\r\n");
  79.  
  80.      FreeMem(buf,MEMSIZE+4);
  81.  }
  82. }
  83.  
  84. extern struct myst my_struct;           /* temp */
  85.  
  86. void DisplayNodeCLog(void)
  87. {
  88.  long loop,stat,which;
  89.  BPTR fh;
  90.  GSTR1[0]='\0';
  91.  AEPutStr("\r\n");
  92.  
  93.  stat=CommandSplit();
  94.  if(stat>1) {
  95.      sscanf(Command[1],"%ld",&which);
  96.      sprintf(GSTR1,"%sNode%ld/Callerslog",Cmds->BBSLoc,which);
  97.      which=0;
  98.      if(stat>2) {
  99.          if((Command[2][0]=='N')||(Command[2][0]=='n')) {
  100.              if((Command[2][1]=='S')||(Command[2][1]=='s'))
  101.                  which=1;
  102.          }
  103.      }
  104.      DisplayCallerslog(GSTR1,which);
  105.      return;
  106.  }
  107.  
  108.      loop=0;
  109.      do  {
  110.          sprintf(GSTR1,"%sNode%ld/Callerslog",Cmds->BBSLoc,loop);
  111.          if(fh=Open(GSTR1,MODE_OLDFILE)) {
  112.              Close(fh);
  113.              sprintf(GSTR1,"%ld - Callerslog for Node %ld\r\n",loop,loop);
  114.              AEPutStr(GSTR1);
  115.              loop++;
  116.          }
  117.      } while(fh!=NULL);
  118.  
  119.      if(loop!=1) {
  120.          AEPutStr("\r\nWhich node to view? ");
  121.          stat=LineInput("",GSTR1,5,KEYBOARD_TIMEOUT);
  122.          if(stat<0||GSTR1[0]=='\0')  {
  123.              AEPutStr("\r\n");
  124.              return;
  125.          }
  126.          sscanf(GSTR1,"%ld",&which);
  127.  
  128.       sscanf(GSTR1,"%ld",&which);
  129.       sprintf(GSTR1,"%sNode%ld/Callerslog",Cmds->BBSLoc,which);
  130.       if(fh=Open(GSTR1,MODE_OLDFILE))
  131.       {
  132.         Close(fh);
  133.         sprintf(GSTR1,"%ld - Callerslog for Node %ld\r\n",which,which);
  134.         AEPutStr(GSTR1);
  135.         sprintf(GSTR1,"%sNode%ld/Callerslog",Cmds->BBSLoc,which);
  136.         DisplayCallerslog(GSTR1,0);
  137.         return;
  138.       }
  139.       else AEPutStr("\r\nNot a valid node!\r\n");
  140.  
  141.    }
  142. }
  143.  
  144.